﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OutlookCalendar.Model
{
    public class Appointment : BindableObject
    {
        private string subject;

        public string wrpatText(string value)
        {
             string rez = "";
             string rz = "";
            string[] words=value.Split(' ');
            string line = "";
            for (int y = 0; y < words.Length; y++)
            {
                line = line + words[y] + " ";
                if (line.Length < 30)
                {
                    rz = rz + words[y]+" ";
                }
                else
                {
                    line = words[y] + " ";
                    rz = rz + Environment.NewLine + words[y] + " ";
                }
            }
            rz = rz.Substring(0, rz.Length - 1);
            int sk = value.Length / 30;
            int i = 0;
            try
            {
                for (i = 0; i < sk; i++)
                {

                    rez = rez + value.Substring(0 + i * 30, 30) + Environment.NewLine;

                }
                rez = rez + value.Substring(0 + i * 30);
            }
            catch (Exception ex) { rez = rez + value.Substring(0 + i * 30); }
            return rz;
        }

        public string Subject 
        {
            get { return subject; }
            set
            {
                if (subject != value)
                {
                    subject = wrpatText(value);
                    RaisePropertyChanged("Subject");
                }
            }
        }

        private string location;
        public string Location
        {
            get { return location; }
            set
            {
                if (location != value)
                {
                    location = value;
                    RaisePropertyChanged("Location");
                }
            }
        }

        private DateTime startTime;
        public DateTime StartTime
        {
            get { return startTime; }
            set
            {
                if (startTime != value)
                {
                    startTime = value;
                    RaisePropertyChanged("StartTime");
                }
            }
        }

        private DateTime endTime;
        public DateTime EndTime
        {
            get { return endTime; }
            set
            {
                if (endTime != value)
                {
                    endTime = value;
                    RaisePropertyChanged("EndTime");
                }
            }
        }

        private string body;
        public string Body
        {
            get { return body; }
            set
            {
                if (body != value)
                {
                    body = value;
                    RaisePropertyChanged("Body");
                }
            }
        }
        
        public override string ToString()
        {
            return Subject;
        }

    
    }
}
